const path = require('path')

const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const initdata = require('./utils/initdata')

const user = require('./router/user.js')
const goods = require('./router/goods.js')
const swiper = require('./router/swiper.js')

const app = express()

initdata('./db/goods.json')
app.use(cors())

// const jsonParser = bodyParser.json()
// const urlencodedParser = bodyParser.urlencoded({ extended: true })

app.use(express.static(path.join(__dirname, 'public')))


app.use('/user', user)
app.use('/goods', goods)
app.use('/swiper', swiper)

app.listen(8888, ()=>{
    console.log('server ok');
})